﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccess;
namespace SQT.tracnghiem.Ajax.ASP.Events
{
    public partial class send_server_gdoc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int event_id = int.Parse(Request.QueryString["event_id"]);
            int? question = null, status = null, player = null, score = null, ring = null;

            if (Request.QueryString["question"] != "")
                question = int.Parse(Request.QueryString["question"]);
            if (Request.QueryString["status"] != "")
                status = int.Parse(Request.QueryString["status"]);
            if (Request.QueryString["player"] != "")
                player = int.Parse(Request.QueryString["player"]);
            if (Request.QueryString["score"] != "")
                score = int.Parse(Request.QueryString["score"]);
            if (Request.QueryString["ring"] != "")
                ring = int.Parse(Request.QueryString["ring"]);

            var get_gdoc = new TblEventCrossWordController().FetchAll().Where(x => x.EventId == event_id);
            if(get_gdoc.ToList().Count!=0)
            {
                new TblEventCrossWordController().Update(get_gdoc.Single().Id, event_id, question, status, player, score, ring);
            }
            else
            {
                new TblEventCrossWordController().Insert(event_id, question, status, player, score, ring);
            }

        }
    }
}